<template>
    <Layout>
        <Form ref="queryForm" :model="dataToQuery" :label-width="125">
            <Row  class="query-form">
                <Col span="8" :offset="16">
                    <!--<Button @click="switchQuery(true)" class="ivu-btn-switch" type="text">展开∨</Button>-->
                    <Button type="primary" class="ivu-btn-reset" icon="md-cloud-download" @click="exportFormSubmit">导出</Button>
                    <Button type="primary" class="ivu-btn-query" icon="md-search" @click="query(1)">全局统计</Button>
                    <Button type="primary" class="ivu-btn-query" icon="md-search" @click="query(0)">本周统计</Button>
                </Col>
            </Row>
        </Form>
        <Table ref='table' :height="tableHeight" no-data-text="没有查询到相关数据!" @on-selection-change='getSelectRows'
               :loading='pageStatus.loading'
               border :columns="columns1" :data="dataTable">
        </Table>
       <!-- <Row style="margin-right:10px;">
            <Col span="24">
                <Page style="float: right" :total="pagedata.total" :page-size="pagedata.pageSize"
                      @on-change="pageChange" @on-page-size-change="pageSizeChange" :page-size-opts="pageSizeArray"
                      show-total show-sizer show-elevator/>
            </Col>
        </Row>
-->
    </Layout>
</template>

<script>
    import {Api} from '@/api/index.js'
    var cascaderDom = () => import('@/components/cascader-dom.vue');
    import {sessionStorage, cookie} from '@/common/cacheUtils.js';
    import pageCommonFunction from '@/components/pageCommonFunction.js'
    export default {
        components: {cascaderDom},
        data() {
            return {
                ...this.createCommonDataField(),
                columns1: [
                    // {title: '序号', width: 80, fixed: 'left', align: 'center', render: this.indexColumnsRender},
                    {key: 'org_name', title: '二级集团',  align: 'center', minWidth: 200},
                    {title: '安全管理', align: 'center', children: [
                            {key: 'login_info_statistics', title: '登录次数', align: 'center', minWidth: 100,
                                render: (h, params) => {return h('span', params.row.login_info_statistics?params.row.login_info_statistics:0)}},
                            {key: 'SA_ACC_BRIEF', title: '事故管理', align: 'center', minWidth: 100},
                            {key: 'sa_cul_activities_programme', title: '安全文化', align: 'center', minWidth: 100},
                            {key: 'sa_risk_info', title: '风险防控', align: 'center', minWidth: 100},
                            {key: 'sa_plan_main1', title: '监督检查', align: 'center', minWidth: 100},
                            {key: 't_apsg_plan', title: '隐患管理', align: 'center', minWidth: 100},
                            {key: 'TB_ROC_SAFE_PTW_DOC', title: '作业许可', align: 'center', minWidth: 100},
                            {key: 'sa_isp_staff', title: '相关方管理', align: 'center', minWidth: 100}]},
                    {title: '环境管理', align: 'center', children: [
                            {key: 'en_evt', title: '环境事件', align: 'center', minWidth: 100},
                            {key: 'sa_plan_main2', title: '监督检查', align: 'center', minWidth: 100},]},
                    {title: '事务管理', align: 'center', children: [
                            {key: 'meeting_receipt', title: '会议回执', align: 'center', minWidth: 100},
                            {key: 'sa_train_law_receipt', title: '培训回执', align: 'center', minWidth: 100}]},

                    {title: '基本信息', align: 'center', children: [
                            {key: 'sa_company_envinfo', title: '企业信息', align: 'center', minWidth: 100},
                            {key: 'sa_staff_envinfo', title: '人员信息', align: 'center', minWidth: 100},
                            {key: 'sa_honor_statis', title: '工作荣誉', align: 'center', minWidth: 100},
                            {key: 'sa_security_engineer_pass_rate', title: '注册安全工程师', align: 'center', minWidth: 100},]},
                    {title: '环保报表', align: 'center', children: [
                            {key: 'en_rpt_investment', title: '本年度环保提升项目完成情况', align: 'center', minWidth: 100},
                            {key: 'en_rpt_investment_plan', title: '次年环保投入计划', align: 'center', minWidth: 100},
                            {key: 'en_rpt_investment_plan', title: '环保投入汇总表', align: 'center', minWidth: 100},
                            {key: 'en_rpt_annual', title: 'ESG环境报表', align: 'center', minWidth: 100},
                            {key: 'en_rpt_semi_annual', title: '环境信息报表', align: 'center', minWidth: 100},
                            {key: 'en_prd_audit_form', title: '清洁生产信息报送单', align: 'center', minWidth: 100},
                            {key: 'en_prd_evaluation_form', title: '审核综合考评汇总表', align: 'center', minWidth: 100},
                            {key: 'en_dsp_info', title: '排污许可证管理', align: 'center', minWidth: 100},] },
                    {title: '安全报表', align: 'center', children: [
                            {key: 'en_rpt_supervise_inspect', title: '安全监督检查', align: 'center', minWidth: 100},] },
                ],
                tableHeight: '',
                companyId:'',
                buttonLoading:false,
                // api
                queryUrl: Api.weekStatis,
                exportUrl:Api.exportWeekStatis,
            }
        },
        mounted() {
            this.companyId=sessionStorage('userId').getObject('userId').companyId
            this.tableHeight = window.innerHeight - this.$refs.table.$el.offsetTop - 145;
            this.query(1);
        },
        methods: {
            ...pageCommonFunction,
            query(type) {
                if (type===1) {
                    this.dataToQuery.type=null
                }else {
                    this.dataToQuery.type=1
                }
                this.queryAjax();
            },
        },
        computed: {},

    }
</script>

<style lang='css' scoped>
    @import '../../../index.css';
</style>
